<script setup>
import NewsItems from "../components/NewsItems.vue"
</script>

<template>

    <div class="common-layout">
        <!-- 标题 -->
        <el-header class="element-center">
            <h1>{{ title }}</h1>
        </el-header>

        <el-container>
            <!-- 侧边空白 -->
            <el-aside width="10%"></el-aside>
            <el-container style="border: 2px,gray,solid;">
                <el-main>
                    <el-row v-for="(item, index) in information" :key="index">
                        <!-- 赋予数据并循环该项 -->

                        <NewsItems :information="item"></NewsItems>
                    </el-row>
                </el-main>
            </el-container>
            <el-aside width="10%"></el-aside>
        </el-container>
    </div>


</template>

<script>
export default {
    setup() {

    },
    data() {
        return {
            title: '最新收录词条',
            information: [
                {
                    id: "1",
                    title: "未加载出",
                    intro: "未加载出",
                    url: "未加载出",
                },]

        }

    },
    created() {
        this.getAllBaidubaikeData();
    },
    methods: {
        getAllBaidubaikeData() {
            this.$axios.get('/index.php/index/getAllBaidubaikeData')
                .then(response => {
                    console.log("userwaitdata的请求状态：" + response.data.message);
                    console.log("userwaitdata请求到的数据：");
                    console.log(response.data.data);
                    this.information = response.data.data;
                })
                .catch(error => {
                    console.error('Error fetching data:', error);
                    this.message = 'Error: ' + error.message;
                });
        },
    }

}
</script>

<style>
.element-center {
  display: flex;
  justify-content: center;
}
</style>